const path = require('path');
const UploadToTencentCOS = require('./plugins/upload-tencent-cos.js');

module.exports = {
  mode: 'production',
  entry: './src/index.js',
  output:{
    path: path.resolve(__dirname, './dist'),
    filename: '[name].js'
  },
  resolveLoader:{
    modules:['node_modules', path.resolve(__dirname, './loaders')]
  },
  module:{
    rules:[
      {
        test: /\.js$/,
        use:{
          loader: 'babel-loader',
          options:{
            presets: [
              ['@babel/preset-env', {modules:false}]
            ]
          }
        }
        // 测试inline-loader配置
        // use:{
        //   loader: 'loaderEnforce'
        // },
        // enforce: 'pre'
      },
      {
        test:/\.worker\.js$/,
        use:{
          loader: 'worker-loader',
          options:{
            inline: true,
            name: '[name].bundler.js'
          }
        }
      },
      {
        test: /\.less$/,
        use:['style-loader','css-loader','less-loader']
      },
      {
        test: /\.(jpg|png)$/,
        use: {
          loader:'url-loader',
          options:{
            limit: 200 * 1024
          }
        }
      }
    ]
  },
  plugins:[
    new UploadToTencentCOS({
      Bucket: 'upload-file-1259343198',
      Region: 'ap-shenzhen-fsi',
      SecretId: 'AKIDQccNs603f05zf3y2kAQO9espXzB69CPN',
      SecretKey: 'tVrxmKm0xd2B4fz6ziHbfSyEH4aw2yez'
    })
  ]
}